<script type="text/javascript">
	$(document).ready(function(){
		/*html_temp = $('#incre_upload').clone(true).html();
		
		$('#add_upload').live('click',function(){
			$("#incre_upload").append(html_temp);
			return false;
		});*/
		
	});
	function check_submit()
	{
		$('#save_post').submit();
	}
	function chane_tab(value)
	{
		if(value == '1')
		{
			$('.tong_quat').toggle('slow');
			$('.du_lieu').hide();
			$('.hinh_anh').hide();
		}
		if(value == '2')
		{
			$('.tong_quat').hide();
			$('.du_lieu').toggle('slow');
			$('.hinh_anh').hide();
			
		}
		if(value == '3')
		{
			$('.tong_quat').hide();
			$('.du_lieu').hide();
			$('.hinh_anh').toggle('slow');
			
		}
	}
	
	$(function() {
		$( "#created" ).datepicker();
	});
</script>
<div>
	<div class="content_navigation">
		<div class="content_post_title pt14">
			<div class="button left" onclick='location.href="<?=base_url().'index.php/admin/'.$module.'/'?>"'>Back</div>
			<div class="button left" onclick="return chane_tab('1');">Tổng quát</div>
			<div class="button left" onclick="return chane_tab('2');">Dữ liệu</div>
			<div class="button left" onclick="return chane_tab('3');">Hình ảnh</div>
		</div>
		<div class="content_post_action pt14">
			<div class="button left" onclick="return check_submit();">Save</div> 
			<div class="button left" onclick="location.href='<?=base_url().'index.php/admin/'.$module.'/save_exit'?>'">Save & Exit</div>
			<div class="button left" onclick="location.href='<?=base_url().'index.php/admin/'.$module.'/'?>'">Cancel</div>
		</div>
		<div class="clearAll"></div>
	</div>
	<div class="content_main_box">
		<form action="<?=base_url().'index.php/admin/'.$module.'/save'?>" method="POST" enctype="multipart/form-data" name="save_post" id="save_post">
		<input type="hidden" name="hidden_id" value="<?=!empty($result['id'])?$result['id']:0?>" />
		<!-- BEGIN tổng quát -->
		<div class="tong_quat">
			<div class="content_main_content">
				<div class="wrap_box_input">
					<div class="wrap_text">Active:</div>
					<div class="wrap_input">
						<input type="checkbox" name="status" id="status" class="mt11" 
						<?php if(isset($result['status'])){if($result['status'] == 1){?> checked="checked" <?php }}else{?> checked="checked" <?php } ?>/>			   	   
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">NAME:</div>
					<div class="wrap_input">
						<input type="text" name="name" id="name" class="input mt3" value="<?=!empty($result['name'])?$result['name']:''?>" placeholder="Tên của sản phẩm."/>	
					</div>
					<div class="clearall"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Address:</div>
					<div class="wrap_input">
						<input placeholder="Giới thiệu ngắn về sản phẩm." type="text" name="address" id="address" class="input mt3" value="<?=!empty($result['address'])?$result['address']:''?>"/>				
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Yahoo:</div>
					<div class="wrap_input">
						<input type="text" name="yahoo" id="yahoo" class="input mt3" value="<?=!empty($result['yahoo'])?$result['yahoo']:''?>" placeholder="Nick Yahoo."/>	
					</div>
					<div class="clearall"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Sky:</div>
					<div class="wrap_input">
						<input type="text" name="sky" id="sky" class="input mt3" value="<?=!empty($result['sky'])?$result['sky']:''?>" placeholder="Nick Sky."/>	
					</div>
					<div class="clearall"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Mail:</div>
					<div class="wrap_input">
						<input type="text" name="mail" id="mail" class="input mt3" value="<?=!empty($result['mail'])?$result['mail']:''?>" placeholder="Gmail."/>	
					</div>
					<div class="clearall"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Phone:</div>
					<div class="wrap_input">
						<input type="text" name="mobile" id="mobile" class="input mt3" value="<?=!empty($result['mobile'])?$result['mobile']:''?>" placeholder="Số điện thoại."/>	
					</div>
					<div class="clearall"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Long:</div>
					<div class="wrap_input">
						<input type="text" name="long" id="long" class="input mt3" value="<?=!empty($result['long'])?$result['long']:''?>" placeholder="Kinh độ."/>	
					</div>
					<div class="clearall"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Lat:</div>
					<div class="wrap_input">
						<input type="text" name="lat" id="lat" class="input mt3" value="<?=!empty($result['lat'])?$result['lat']:''?>" placeholder="Vĩ độ."/>	
					</div>
					<div class="clearall"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Order:</div>
					<div class="wrap_input">
						<input type="text" name="order" id="order" class="input mt3" value="<?=!empty($result['order'])?$result['order']:''?>" placeholder="Sắp xếp thứ tự xuất hiện."/>	
					</div>
					<div class="clearall"></div>
				</div>
			</div>
		</div>
		<!-- END Tổng quát -->
		<!-- BEGIN Dư lieu -->
		<div class="du_lieu" style="display:none;height:auto;padding-bottom:15px;">
			<div class="content_main_content">
				<div class="wrap_box_input">
					<div class="wrap_text">Active:</div>
					<div class="wrap_input">
						<input type="checkbox" name="status" id="status" class="mt11" 
						<?php if(isset($result['status'])){if($result['status'] == 1){?> checked="checked" <?php }}else{?> checked="checked" <?php } ?>/>			   	   
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Is best sale:</div>
					<div class="wrap_input">
						<input type="checkbox" name="is_bestsale" id="is_bestsale" class="mt11" 
						<?php if(isset($result['is_bestsale'])){if($result['is_bestsale'] == 1){?> checked="checked" <?php }}else{?> checked="checked" <?php } ?>/>			   	   
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Category:</div>
					<div class="wrap_input">
						<select name="category_id" id="category_id" class="input">
							<option value="">-- Select Category --</option>
							<?php 
							foreach($categories as $cat){
								$select ='';
								if(!empty($result['category_id']))
								{
									$select = ($result['category_id'] == $cat['id'])? 'selected':'' ;
								}
								echo "<option value='{$cat['id']}' $select>{$cat['name']}</option>";
							}
							?>
						</select>			
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Available:</div>
					<div class="wrap_input">
						<select name="available_id" id="available_id" class="input">
							<option value="">-- Select Available --</option>
							<?php 
							foreach($available as $avai):
								$select ='';
								if(!empty($result['available_id']))
								{
									$select = ($result['available_id'] == $avai['id'])? 'selected':'' ;
								}
								echo "<option value='{$avai['id']}' $select>{$avai['name']}</option>";
							endforeach;?>
						</select>
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Promotion:</div>
					<div class="wrap_input">
						<select name="promotion_id" id="promotion_id" class="input">
							<option value="0">-- Select Promotion --</option>
							<?php 
							foreach($promotion as $pro):
								$select ='';
								if(!empty($result['promotion_id']))
								{
									$select = ($result['promotion_id'] == $pro['id'])? 'selected':'' ;
								}
								echo "<option value='{$pro['id']}' $select>{$pro['name']}</option>";
							endforeach;
							?>
						</select>
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Slug:</div>
					<div class="wrap_input">
						<input type="text" name="slug" id="slug" class="input mt3" value="<?=!empty($result['slug'])?$result['slug']:''?>" placeholder="Seo link."/>	
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Price:</div>
					<div class="wrap_input">
						<input type="text" name="price" id="price" class="input mt3" value="<?=!empty($result['price'])?$result['price']:''?>" placeholder="Giá sản phẩm."/>				
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Price Promotion:</div>
					<div class="wrap_input">
						<input type="text" name="price_promotion" id="price_promotion" class="input mt3" value="<?=!empty($result['price'])?$result['price']:''?>" placeholder="Giá khuyến mãi."/>				
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Amount:</div>
					<div class="wrap_input">
						<input type="text" name="amount" id="amount" class="input mt3" value="<?=!empty($result['amount'])?$result['amount']:''?>" placeholder="Số lượng sản phẩm."/>
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Size:</div>
					<div class="wrap_input">
						<input type="text" name="size" id="size" class="input mt3" value="<?=!empty($result['size'])?$result['size']:''?>" placeholder="Kích cỡ sản phẩm."/>				
					</div>
					<div class="clearAll"></div>
				</div>
				<div class="wrap_box_input">
					<div class="wrap_text">Order:</div>
					<div class="wrap_input">
						<input type="text" name="order" id="order" class="input mt3" value="<?=!empty($result['order'])?$result['order']:''?>" placeholder="Sắp xếp thứ tự xuất hiện sản phẩm."/>	
					</div>
					<div class="clearAll"></div>
				</div>
			</div>
		</div>
		<!-- END Dữ liệu -->
		<!-- BEGIN Hình ảnh -->
		<div class="hinh_anh" style="display:none;height:auto;padding-bottom:15px;">
			<div class="content_main_content">
				<div class="wrap_box_input">
					<div class="wrap_text">Image thumb:</div>
					<div class="wrap_input" style="width:532px;">
						<input type="file" name="image_thumb" id="image_thumb" class="mt3"/>				
					</div>
					<div class="wrap_input" style="padding-top:2px;">
						<?php 
						if(isset($result['image_frontend']))
						{
						?>
							<img src="<?=base_url().'static/uploads/images/thumb/'.$result['image_frontend']?>" alt="" width="56px;" height="56x;"/>		
						<?php } ?>			  
					</div>
					<div class="clearall"></div>
				</div>
				<!--<div class="content_main_input">
					<div class="main_text">Image thumb(multiple):</div>
					<div class="main_input" style="width:532px;">
						<input type="file" name="image_thumb" id="image_thumb" class="main_input_text" multiple="multiple"/>				</div>
					<div class="main_input" style="padding-top:2px;">
						<?php 
						if(isset($result['image_frontend']))
						{
						?>
							<img src="<?=base_url().'static/uploads/images/thumb/'.$result['image_frontend']?>" alt="" width="56px;" height="56x;"/>		
						<?php } ?>			  
					</div>
					<div class="clearall"></div>
				</div>-->
			</div>
		</div>
		<!-- END Hình ảnh -->
		</form>
	</div>
</div>